#!/bin/bash

adduser(){
	read -p "请输入要添加的用户名:" username
	id $username &> /dev/null && echo "用户名已存在!" || useradd $username
}

del(){
	read -p "请输入要删除的用户名:" username
	userdel -r $username &> /dev/null && echo "删除成功" || echo "用户不存在!"
}

mod(){
	read -p "请输入(用户id，用户属组，用户家目录):" userid usergroup userhome username
       usermod -u $userid -g $usergroup -d $userhome $username &> /dev/null && echo "修改成功" || echo "修改失败"	
}

while :
do
echo "#################"
echo "1.添加用户"
echo "2.删除用户"
echo "3.修改指定用户"
echo "4.退出"
echo "#################"

read -p "请输入你的选择:" options
case $options in 
	1)
		adduser
		;;
	2)
		del
		;;
	4)
		exit
		;;
	3)
		mod
		;;
	*)
		echo "请输入1-4"
esac
done

